class LinkSegment extends egret.Sprite {
	public static SIZE: number;
	public static INTERVAL: number;
	private _baseColor: number = 0;
	private _size: number = 0;
	private tendrilList: Array<Tendril>;
	private _load: number = 0;

	public constructor(sync: Sync, baseColor: number) {
		super();
		this._size = (LinkSegment.SIZE / 2);
		this.tendrilList = new Array();
		this._baseColor = (baseColor);
		var tendril: Tendril = new Tendril(Tendril.TYPE_WITHOUT_SPOT, this._size, 110, 0, 0.3, 1.3, false, sync);
		this.addChild(tendril);
		this.tendrilList.push(tendril);
		tendril = new Tendril(Tendril.TYPE_WITHOUT_SPOT, this._size, -110, 0, 0.3, 1.3, true, sync);
		this.addChild(tendril);
		this.tendrilList.push(tendril);
	}

	public setSize(size: number) {
		var t: Tendril;
		this._size = (size / 2);
		var i: number = 0;
		while (i < this.tendrilList.length) {
			t = this.tendrilList[i];
			t.setBaseRadius(this._size);
			i++;
		}
		this.draw();
	}

	public get load(): number {
		return (this._load);
	}

	public set baseColor(baseColor: number) {
		baseColor = (baseColor);
		this._baseColor = (baseColor);
		this.draw();
	}

	public setTendrilSize(size: number) {
		var t: Tendril;
		var i: number = 0;
		while (i < this.tendrilList.length) {
			t = this.tendrilList[i];
			t.setSize(size);
			i++;
		}
	}

	public setLoad(load: number) {
	
		this._load = (load);
		if (load > 0) {
			this.filters = [new egret.GlowFilter(0xFFFF00, 0.8)];
		}
		else {
			this.filters = null;
		}
	}

	public get baseColor(): number {
		return (this._baseColor);
	}

	private draw() {
		var gr: egret.Graphics = this.graphics;
		gr.clear();
		gr.lineStyle(1, GUI.OUTLINE_COLOR);
		gr.drawCircle(0, 0, this._size);
		gr.lineStyle();
		gr.beginFill(this._baseColor);
		gr.drawCircle(0, 0, (this._size - 1));
		gr.endFill();
	}

	public destruct() {
		var t: Tendril;
		this.graphics.clear();
		var i: number = 0;
		while (i < this.tendrilList.length) {
			t = this.tendrilList[i];
			t.destruct();
			i++;
		}
	}

}

LinkSegment.SIZE = 7;
LinkSegment.INTERVAL = 4;

